<?php
namespace app\api\controller\appeal;
use app\common\controller\BaseController;
use app\common\service\appeal\ShopOrderAppealService;
use app\common\validate\appeal\ShopOrderAppealValidate;
use hg\apidoc\annotation as Apidoc;
/**
 * @Apidoc\Title("订单申诉")
 * @Apidoc\Group("appeal")
 * @Apidoc\Sort("250")
 */
class ShopOrderAppeal extends BaseController
{

    /**
    * @Apidoc\Title("申诉中心信息")
    * @Apidoc\Query(ref="app\common\model\appeal\ShopOrderAppealModel", field="id")
    * @Apidoc\Returned(ref="app\common\model\appeal\ShopOrderAppealModel")
    */
    public function info()
    {
        $param = $this->params(['order_id/d' => null]);
        validate(ShopOrderAppealValidate::class)->scene('infoByOrderID')->check($param);
        $data = ShopOrderAppealService::infoByOrderID($param['order_id'],member_id(true));
        return success($data);
    }

    /**
     * @Apidoc\Title("申诉回复")
     * @Apidoc\Method("POST")
     * @Apidoc\Param(ref="app\common\model\appeal\ShopOrderAppealModel", field="id,is_disable,mer_id,shop_order_id,shop_order_on,setting_appeal_type_id,is_terminal,data_id,status,is_tip,remark")
     */
    public function reply()
    {
        $param = $this->params(['id/d' => null,'is_terminal/d' => 1, 'content/s' => '', 'image_ids/a' => []]);
        validate(ShopOrderAppealValidate::class)->scene('reply')->check($param);
        $data = ShopOrderAppealService::reply($param['id'], $param);
        return success($data);
    }
    /**
     * @Apidoc\Title("申诉完结")
     * @Apidoc\Method("POST")
     * @Apidoc\Param(ref="app\common\model\appeal\ShopOrderAppealModel", field="id,is_disable,mer_id,shop_order_id,shop_order_on,setting_appeal_type_id,is_terminal,data_id,status,is_tip,remark")
     */
    public function end()
    {
        $param = $this->params(['ids/a' => []]);
        validate(ShopOrderAppealValidate::class)->scene('end')->check($param);
        $data = ShopOrderAppealService::end($param['ids'],2);
        return success($data);
    }
}
